﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tycho.Runtime;
using System.Transactions;
using Tycho.Language;

namespace TychoTest {
    [TestClass]
    public class TestDynamicFrame {
        DynamicFrameObject Frame;
        Symbol A, B;

        [TestInitialize]
        public void Setup () {
            Frame = new DynamicFrameObject ();
            A = Modules.User.Get ("a");
            B = Modules.User.Get ("b");
        }

        [TestMethod]
        public void TestGetVariables () {
            Frame [A] = "something";
            Frame [B] = "bex";

            var variables = Frame.Variables;
            Assert.IsTrue (variables.Contains (A));
            Assert.IsTrue (variables.Contains (B));
        }

        [TestMethod]
        public void TestSetGetVariable () {
            Frame [A] = RuntimeModule.CreateString ("A");
            Frame.SetVariable (Frame, B, 0, RuntimeModule.CreateString ("B"));

            Assert.AreEqual ("A", Frame.GetVariable (Frame, A, 0).ExpectValue<string> ());
            Assert.AreEqual ("B", Frame [B].ExpectValue<string> ());
        }
    }
}
